/**
 * 
 */
package com.base.myproject.server;

import java.sql.ResultSet;
import java.util.Date;

import com.base.myproject.server.database.PoolMan;

/**
 * @author zgw
 *2009-7-14 上午09:58:39
 * javazgw@gmail.com
 */
public class User {
	String name;
	String group;
	String lastlogintime;
	String bcode;
	String email;
	public User()
	{
		
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getGroup() {
		return group;
	}
	public void setGroup(String group) {
		this.group = group;
	}
	public String getLastlogintime() {
		return lastlogintime;
	}
	public void setLastlogintime(String lastlogintime) {
		this.lastlogintime = lastlogintime;
	}
	public String getBcode() {
		return bcode;
	}
	public void setBcode(String bcode) {
		this.bcode = bcode;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	public static User CreateUser(String code) throws Exception
	{
		User u = new User();
		String sql = "select bcode,bname,departments,email from bcode where bcode ='"+code+"'";
		  PoolMan pm = new PoolMan();
		  ResultSet rs = pm.executeQuery(sql);
		 if(rs.next())
		 {
			String bcode =  rs.getString("bcode");
			 String bname = rs.getString("bname");
			 String  departmenets = rs.getString("departments");
			 String email = rs.getString("email");
			 u.setBcode(bcode);
			 u.setName(bname);
			 u.setGroup(departmenets);
			 u.setEmail(email);
			 Date d = new Date();
			java.text.SimpleDateFormat s = new java.text.SimpleDateFormat("yyy-MM-dd HH:mm:ss");
	
			 u.setLastlogintime(s.format(d));
			 
		 }
		  
		return u;
		
	}
}
